unit uPopupModule ;

interface

uses
  SysUtils,
  Classes,
  ActnList,
  Menus,
  uGHWReader,
  ImgList,
  Controls ;

type
  TdmPopup = class( TDataModule )
    ActionList : TActionList ;
    actHex : TAction ;
    actDec : TAction ;
    actOctal : TAction ;
    actBinary : TAction ;
    actFloat : TAction ;
    ImageList : TImageList ;
    actEnum: TAction;
    pumValueFormat: TPopupMenu;
    N1: TMenuItem;
    Cancel1: TMenuItem;
    Binary1: TMenuItem;
    Decimal1: TMenuItem;
    Enumerate1: TMenuItem;
    Floating1: TMenuItem;
    Hexadecimal1: TMenuItem;
    Octal1: TMenuItem;
    N3: TMenuItem;
    actPicoBlaze3: TAction;
    actPicoBlaze6: TAction;
    PicoBlaze31: TMenuItem;
    PicoBlaze61: TMenuItem;
    procedure actHexExecute( Sender : TObject ) ;
    procedure actDecExecute( Sender : TObject ) ;
    procedure actOctalExecute( Sender : TObject ) ;
    procedure actBinaryExecute( Sender : TObject ) ;
    procedure actHexUpdate( Sender : TObject ) ;
    procedure actDecUpdate( Sender : TObject ) ;
    procedure actOctalUpdate( Sender : TObject ) ;
    procedure actBinaryUpdate( Sender : TObject ) ;
    procedure actFloatExecute( Sender : TObject ) ;
    procedure actFloatUpdate( Sender : TObject ) ;
    procedure actEnumExecute(Sender: TObject);
    procedure actEnumUpdate(Sender: TObject);
    procedure actPicoBlaze3Update(Sender: TObject);
    procedure actPicoBlaze6Execute(Sender: TObject);
    procedure actPicoBlaze6Update(Sender: TObject);
    procedure actPicoBlaze3Execute(Sender: TObject);
  private
    fSignal : TGHWSignal ;
    FChoices : TGHWFormatChoices ;
    procedure SetSignal( const Value : TGHWSignal ) ;
    procedure SetChoices( const Value : TGHWFormatChoices ) ;
  public
    property Signal : TGHWSignal read fSignal write SetSignal ;
    property Choices : TGHWFormatChoices read FChoices write SetChoices ;
  end ;

var
  dmPopup : TdmPopup ;

implementation

{$R *.dfm}

procedure TdmPopup.actBinaryExecute( Sender : TObject ) ;
begin
  if assigned( fSignal ) then
    fSignal.ValueFormat := fmtBinary ;
  fSignal := nil ;
end ;

procedure TdmPopup.actBinaryUpdate( Sender : TObject ) ;
begin
  actBinary.Enabled := fmtBinary in Choices ;
end ;

procedure TdmPopup.actDecExecute( Sender : TObject ) ;
begin
  if assigned( fSignal ) then
    fSignal.ValueFormat := fmtDecimal ;
  fSignal := nil ;
end ;

procedure TdmPopup.actDecUpdate( Sender : TObject ) ;
begin
  actDec.Enabled := fmtDecimal in Choices ;
end ;

procedure TdmPopup.actEnumExecute(Sender: TObject);
begin
  if assigned( fSignal ) then
    fSignal.ValueFormat := fmtEnum ;
  fSignal := nil ;
end;

procedure TdmPopup.actEnumUpdate(Sender: TObject);
begin
  actEnum.Enabled := fmtEnum in Choices ;
end;

procedure TdmPopup.actFloatExecute( Sender : TObject ) ;
begin
  if assigned( fSignal ) then
    fSignal.ValueFormat := fmtFloat ;
  fSignal := nil ;
end ;

procedure TdmPopup.actFloatUpdate( Sender : TObject ) ;
begin
  actFloat.Enabled := fmtFloat in Choices ;
end ;

procedure TdmPopup.actHexExecute( Sender : TObject ) ;
begin
  if assigned( fSignal ) then
    fSignal.ValueFormat := fmtHex ;
  fSignal := nil ;
end ;

procedure TdmPopup.actHexUpdate( Sender : TObject ) ;
begin
  actHex.Enabled := fmtHex in Choices ;
end ;

procedure TdmPopup.actOctalExecute( Sender : TObject ) ;
begin
  if assigned( fSignal ) then
    fSignal.ValueFormat := fmtOctal ;
  fSignal := nil ;
end ;

procedure TdmPopup.actOctalUpdate( Sender : TObject ) ;
begin
  actOctal.Enabled := fmtOctal in Choices ;
end ;

procedure TdmPopup.actPicoBlaze3Execute(Sender: TObject);
begin
  if assigned( fSignal ) then
    fSignal.ValueFormat := fmtPB3 ;
  fSignal := nil ;
end;

procedure TdmPopup.actPicoBlaze3Update(Sender: TObject);
begin
  actPicoBlaze3.Enabled := fmtPB3 in Choices ;
end;

procedure TdmPopup.actPicoBlaze6Execute(Sender: TObject);
begin
  if assigned( fSignal ) then
    fSignal.ValueFormat := fmtPB6 ;
  fSignal := nil ;
end;

procedure TdmPopup.actPicoBlaze6Update(Sender: TObject);
begin
  actPicoBlaze6.Enabled := fmtPB6 in Choices ;
end;

procedure TdmPopup.SetChoices( const Value : TGHWFormatChoices ) ;
begin
  FChoices := Value ;
end ;

procedure TdmPopup.SetSignal( const Value : TGHWSignal ) ;
begin
  fSignal := Value ;
end ;

end.
